package reflect;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * 反射调用
 * 
 * @author hai
 * 
 */
public class Fs {

	/**
	 * @param args
	 * @throws IllegalAccessException
	 * @throws InstantiationException
	 */
	public static void main(String[] args) throws InstantiationException,
			IllegalAccessException {
		try {
			Class<?> c = Class.forName("reflect.Student");
			Student s = (Student) c.newInstance();
			Method m = null;
			try {
				m = s.getClass().getDeclaredMethod("asd");
				m.invoke(s);
				Field[] fieldlist = c.getDeclaredFields();
				 for (int i = 0; i < fieldlist.length; i++) {
		                Field fld = fieldlist[i];
		                System.out.println("name = " + fld.getName());
		                System.out.println("type = " + fld.getType().getSimpleName());
		                System.out.println(fld.getGenericType());           
		                System.out.println("-----");           
		                }
			} catch (Exception e) {
				e.printStackTrace();
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}

	}

}
